package com.example.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.sql.Wrapper;
import java.util.List;
//该注解是告诉Spring，让Spring创建一个名字叫“UserMapper”的UserMapperImpl实例。
@Repository
//BaseMapper<User>   通用的Mapper，里面有自定义的增删改查
public interface UserMapper extends BaseMapper<User> {
       @Select("select * from user where id=#{id}")
       User findUserById(Long id);
       //自定义分页操作，参数page，插件会在写的sql语句后面自动加上 limit
       IPage<User> findUserByPage(Page<User> page, String name);
       //使用Wrapper 自定义SQL. @Param(Constants.WRAPPER):注解声明
       List<User> findUsers(@Param(Constants.WRAPPER)Wrapper ew);
}
